package org.lanqiao.tjut.db;

import java.util.List;

import org.apache.commons.dbutils.handlers.BeanListHandler;
import org.lanqiao.tjut.bean.DeptBean;

public class DBTestDriver {

	public static void main(String[] args) {
		test03();
	}
	private static void test03() {		
		// 组织数据查询操作sql语句
		String strSql = "select * from dept where department_id > ?";
		// 数据库操作sql语句的参数
		Object[] params = {60};
		List<DeptBean> lstDepts =  DBFactory.getDBDriverInstance().query(strSql, new BeanListHandler<>(DeptBean.class),params);
					
		// 根据数据操作结果进行业务逻辑处理
		 for (DeptBean deptB : lstDepts) {
			// 使用迭代器遍历实体bean对象
				System.out.println(deptB);
		}
		 
		System.out.println("-------------------");
		System.out.println(lstDepts.get(0).getDepartment_name());
	
}
	private static void test02() {		
			// 4、组织数据操作sql语句
			String strSql = "select * from dept";
			List<DeptBean> lstDepts =  DBFactory.getDBDriverInstance().query(strSql, new BeanListHandler<>(DeptBean.class));
						
			// 6、根据数据操作结果进行业务逻辑处理
			 for (DeptBean deptB : lstDepts) {
				// 使用迭代器遍历实体bean对象
					System.out.println(deptB);
			}
			System.out.println("-------------------");
			System.out.println(lstDepts.get(0).getDepartment_name());
		
	}
}
